package com.szrt.java.day20161223.demo02;

import java.util.Scanner;

import org.junit.Test;

public class SwitchDemo01 {

	/**
	 * 你输入交通工具 我输出你的速度
	 *  == 230   高铁
	 *  == 120   小车
	 *  == 40     电动车
	 *  else    走路  11
	 *  
	 *  1: break break死都要写
	 *  2: byte/short/int/long/char/String
	 *  3: 不管写了多个个。会且只会执行1条语句
	 *  4: 等于的关系
	 * 
	 */
	
	@Test
	public void if01(){
		
		int speed =230;
		
		if(230==speed){
			System.out.println("高铁");
		}else if(120==speed){
			System.out.println("汽车");
		}else if(40==speed){
			System.out.println("电动车");
		}else{
			System.out.println("走路");
		}
	}
	
	@Test
	public void switch01(){
		
		Scanner sc =new Scanner(System.in);
		System.out.println("请输入括号中的行驶时速(230 120 40 <40)：");
		int speed =sc.nextInt();
		
		sc.close();
		
		switch (speed){
		case 230: System.out.println("高铁"); break;
		case 120: System.out.println("汽车"); break;
		case 40: System.out.println("电动车"); break;
		default: System.out.println("走路"); break;
		}
	}
	
	
	@Test
	public void switch02(){
		
		Scanner sc =new Scanner(System.in);
		System.out.println("请输入括号中的交通工具（高铁 汽车 电动车 走路）：");
		String vehicle =sc.next();
		
		sc.close();
		
		switch (vehicle) {
		case "高铁": System.out.println(230); break;
		case "汽车": System.out.println(120); break;
		case "电动车": System.out.println(40); break;
		case "走路": System.out.println(11);break;
		}
	}
	
	@Test
	public void classTest05(){
		
		Scanner sc =new Scanner(System.in);
		System.out.println("请输入你的等级：");
		String level =sc.next();
		sc.close();
		
		switch (level) {
		case "A": System.out.println("你的表现优秀！"); break;
		case "B": System.out.println("你的表现良好！"); break;
		case "C": System.out.println("你的表现一般！"); break;

		default: System.out.println("你的表现有问题！"); break;
		}
	}
}
